package com.grwx.omc.admin.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.grwx.omc.admin.dao.SysProviderMapper;
import com.grwx.omc.admin.entity.SysProvider;
import com.grwx.omc.admin.service.ISysProviderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;

@Service
public class SysProviderServiceImpl extends ServiceImpl<SysProviderMapper, SysProvider> implements ISysProviderService {
    @Autowired
    private SysProviderMapper sysProviderMapper;

    @Override
    public IPage<SysProvider> page(Page<SysProvider> page, SysProvider sysProvider) {
        return sysProviderMapper.pageList(page,sysProvider);
    }

    @Override
    public void addOrUpdate(SysProvider sysProvider) {
        if (null == sysProvider.getId()){
            sysProvider.preInsert();
            save(sysProvider);
        }else {
            sysProvider.preUpdate();
            updateById(sysProvider);
        }
    }

    @Override
    public void del(Long[] ids) {
        removeByIds(Arrays.asList(ids));
    }
}
